extends Card


func play_on_release(card_view: CardView) -> void:
	var player = card_view.get_tree().get_first_node_in_group("player")
	var player_state: PlayerInBattleState = Globals.player_state
	if CardManager.round_data.anger_addition_times == 0:
		CardManager.round_data.anger_addition_times += 1
		CardManager.round_data.anger_addition_card.push_back(self)
	var tween := card_view.create_tween()
	var temp_shield = get_final_shield()
	tween.tween_callback(Shake.state_play.bind(player, StateBar.STATE.SHIELD, temp_shield))
	player_state.shield += temp_shield
	tween.tween_interval(0.31)
	await tween.finished
	card_view.play_on_release_signal_finish.emit()


func get_desc() -> String:
	CardManager.round_data.anger_addition_times += 1
	CardManager.round_data.anger_addition_card.push_back(self)
	var all_shield = get_final_shield()
	var no_anger_shield = Globals.get_final_shield(Globals.player_state, self.shield)
	var anger_shield = all_shield - no_anger_shield
	var shield_str = ""
	if anger_shield == 0:
		shield_str = str(all_shield)
	else:
		shield_str = str(all_shield) + "(" + str(anger_shield) + ")"

	if desc_lab == "":
		return ""
	var text = (
		desc_lab % [shield_str, self.consume_anger, self.anger_addition, self.max_consume_anger]
	)
	CardManager.round_data.anger_addition_times -= 1
	CardManager.round_data.anger_addition_card.pop_back()
	return text


func init_from_csv(introduce):
	super.init_from_csv(introduce)
	self.shield = int(introduce[5])
	self.consume_anger = int(introduce[6])
	self.anger_addition = int(introduce[7])
	self.max_consume_anger = int(introduce[8])
